<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ include file="../common.inc" %>    
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<link href="./css/style1.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="./js/form.js"></script>
<script type="text/javascript" language="javascript">
<!--
	function checkForm2(){
		var objs = document.getElementsByName("id");
		var sign = 0;
		for(var i = 0; i < objs.length; i++){
			if(objs[i].value != 0 && objs[i].checked)sign = sign + 1;
		}
		if(sign <= 0){
			alert("请选择待操作的项！");
			return false;
		}else if(sign > 1){
			alert("只能选择一个待操作项！");
			return false;
		}
		return true;
	}

	function back(){
		window.location.href = "./saleCost.do";
		window.location.target = "main";
	}
	
	function viewSaleCost(saleCostCode){
		window.location.href = "./saleCost.do?action=viewSaleCost&saleCostCode="+saleCostCode+"&sign=3";
		window.location.target = "main";
	}
	
	function advancedAuery(){
		window.location.href = "advancedAuery.html";
		window.location.target = "main";
	}
	
	function updateSaleCost(saleCostCode){
		if(checkForm2()){
			var objs = document.getElementsByName("id");
			var id = 0;
			for(var i = 0; i < objs.length; i++){
				if(objs[i].value != 0 && objs[i].checked){
					id = objs[i].value;
					break;
				}
			}
			window.location.href = "./saleCost.do?action=preUpdateSaleCost&saleCostCode="+id+"&sign=2";
		window.location.target = "main";
		}
	}
	
	function deleteSaleCost(saleCostCode){
		if(checkForm2()){
			var objs = document.getElementsByName("id");
			var id = 0;
			for(var i = 0; i < objs.length; i++){
				if(objs[i].value != 0 && objs[i].checked){
					id = objs[i].value;
					break;
				}
			}
			window.location.href = "./saleCost.do?action=deleteReturnSaleCost&saleCostCode="+id;
		window.location.target = "main";
		}
	}
	
	function pageContract(flag){
		document.returnSaleCostForm.action = "./saleCost.do?action=waitAuditSaleCost&flag="+flag;
		document.returnSaleCostForm.target = "main";
		document.returnSaleCostForm.submit();
	}
	
	function initPage(){
		if("<c:out value='${result}'/>" == 1){
			alert("<fmt:message key='common.message.deleteSuccess'/>");
		}
	}
-->
</script>
</head>
<body onload="initPage()">
<form name="returnSaleCostForm" action="" method="post">
	<table class="table_frame">
		<tr>
			<td>
				<table class="table_title1">
					<tr>
						<td class="title_lab" >退回的费用申请</td>
					</tr>
					<tr>
						<td valign="bottom" class="a_tools" style="padding-left: 3px;padding-top: 4px;">
							<a class="update" href="javascript:updateSaleCost();" hidefocus="true">修改</a>
							<a class="closestage" href="javascript:deleteSaleCost();" hidefocus="true">撤消</a>
						</td>
						<!-- 
						<td></td>
						<td valign="bottom" align="right">
							<a href="javascript:back();" hidefocus="true">返回费用列表</a>&nbsp;&nbsp;
						</td>
						 -->
					</tr>
					<tr><td height="2"></td></tr>
				</table>
			</td>
		</tr>
		<tr>
			<td>
				<table class="table_title2">
					<tr>
						<td class="title_lab">退回的费用申请</td>
						<td align="right" valign="">
							<!-- page -->
							<table class="table_page2">
								<tr>
									<td valign="bottom">
										<img src="./images/frist.bmp" onclick="pageContract(1)" alt="首页" style="vertical-align: middle;cursor: hand;">
										<img src="./images/last.bmp" onclick="pageContract(2)" alt="上一页" style="vertical-align: middle;cursor: hand;">&nbsp;
										<font color="red">${currentPage}</font>/${totalPages}&nbsp;<fmt:message key='common.page'/>&nbsp;
										<img src="./images/next.bmp" onclick="pageContract(3)" alt="下一页" style="vertical-align: middle;cursor: hand;">
										<img src="./images/end.bmp" onclick="pageContract(4)" alt="末页" style="vertical-align: middle;cursor: hand;">
										共&nbsp;&nbsp;${totalRows}&nbsp;<fmt:message key='common.page.totalRow'/>&nbsp;&nbsp;&nbsp;
									</td>
								</tr>
							</table>
						</td>
					</tr>
					<tr><td colspan="3" height="2"></td></tr>
					<tr>
						<td colspan="2">
							<table class="table">
								<tr>
									<td valign="top">
										<!-- 
										<div style="width:800px;height:100%;overflow-x: scroll;overflow-y: hidden;">
										 -->
										<table class="table_style">
											<tr>
												<td class="title" width="8"></td>
												<td class="title" width="30">选择</td>
												<td class="title" width="">单据编号</td>
												<td class="title" width="12%">金额(元)</td>
												<td class="title" width="12%">申请人</td>
												<td class="title" width="15%">申请日期</td>
											</tr>
											<c:forEach var="saleCost" items="${saleCosts}">
											<tr onmouseover="onmousemoveChange(this,'img${saleCost.id}')" onmouseout="onmouseoutChange(this,'img${saleCost.id}')">
												<td height="16" width="8" align="right"><img id="img${saleCost.id}" src="./images/table_sign2.bmp"></td>
												<td align="center">
													<input id="id" name="id" type="checkbox" value="${saleCost.saleCostCode}"/>
												</td>
												<td><a href="javascript:viewSaleCost('${saleCost.saleCostCode}');" target="main">${saleCost.saleCostCode}</a></td>
												<td>${saleCost.costValue}</td>
												<td>${saleCost.applyPerson}</td>
												<td><fmt:formatDate value="${saleCost.applyDate}" pattern="yyyy-MM-dd"/></td>
											</tr>
											</c:forEach>
										</table>
										<!-- 
										</div>
										 -->
									</td>
								</tr>
								<tr>
									<td align="left" valign="bottom">
										<!-- page -->
										<table id="tp" class="table_page">
											<tr>
												<td>&nbsp;&nbsp;
													<img src="./images/frist.bmp" onclick="pageContract(1)" alt="首页" style="vertical-align: middle;cursor: hand;">
													<img src="./images/last.bmp" onclick="pageContract(2)" alt="上一页" style="vertical-align: middle;cursor: hand;">&nbsp;
													<font color="red">${currentPage}</font>/${totalPages}&nbsp;<fmt:message key='common.page'/>&nbsp;
													<img src="./images/next.bmp" onclick="pageContract(3)" alt="下一页" style="vertical-align: middle;cursor: hand;">
													<img src="./images/end.bmp" onclick="pageContract(4)" alt="末页" style="vertical-align: middle;cursor: hand;">
													共&nbsp;&nbsp;${totalRows}&nbsp;<fmt:message key='common.page.totalRow'/>
												</td>
											</tr>
										</table>
									</td>
								</tr>
							</table>
						</td>
					</tr>
				</table>
			</td>
		</tr>
	</table>
</form>	
</body>
</html>